/*
 * Feb/13/2013
 * 
 * Group 2
 * ITCS 3146
 * 
 * Group Project
 * MULTICS Paging Algorithm
 * 
 */



package MULTICS;

import java.util.*;

public class MainDriver 
{

	public static void main(String[] args) 
	{
		MemorySystem memSystem = new MemorySystem();
		memSystem.PopulateRAM();
		
		
		Scanner input = new Scanner(System.in);
		String repeat = null;
		
		
		System.out.println("MULTICS Paging Algorithm\n\n");
		
		
		
		do
		{
			
			System.out.println("Do you want to see the memory status?<y/n>");
			String viewStat = input.nextLine();
			
			if(viewStat.charAt(0) == 'y')
				System.out.println(memSystem.pageSegmentReport());

		
			System.out.println("\nMemory Reference\n---------------------\n");
			
			System.out.println("Segment:");
			int segmentNumb = input.nextInt();
		
			System.out.println("Page:");
			int pageNumb = input.nextInt();
		
			System.out.println("Page Offset:");
			int pageOffset = input.nextInt();
		
			System.out.println("Operation:");
			String op = input.nextLine();
			op = input.nextLine();
		
			boolean reference = memSystem.memoryReference(segmentNumb, pageNumb, pageOffset,op);
			
			if(!reference)
				System.out.println("Memory Reference Failed");
			
			System.out.println("Do you want to see the memory status?<y/n>");
			viewStat = input.nextLine();
			
			if(viewStat.charAt(0) == 'y')
				System.out.println(memSystem.pageSegmentReport());
			
			
			System.out.println("Do you want to make another memory reference? <y/n>");
			repeat = input.nextLine();
			
				
		
		}while(repeat.charAt(0)=='y');
		
		
		
		input.close();
	
		
		

	}

}
